package com.study.talk.module.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.study.talk.module.entity.vo.RegisterUserVo;
import com.study.talk.module.entity.vo.UserInfoVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

/**
 * <p>
 * 
 * </p>
 *
 * @author thor
 * @since 2023-12-18
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("user")
@ApiModel(value = "User对象", description = "")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("用户id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("用户名")
    private String username;

    @ApiModelProperty("用户密码")
    private String password;

    @ApiModelProperty("用户手机号")
    private String phoneNumber;

    @ApiModelProperty("创建日期")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;



    public User(RegisterUserVo userVo){
        this.username = userVo.getUsername();
        this.password = userVo.getPassword();
        this.phoneNumber = userVo.getPhoneNumber();
    }

    public User(UserInfoVo userVo){
        this.username = userVo.getUsername();
        this.password = userVo.getPassword();
        this.phoneNumber = userVo.getPhone();
    }

}
